<?php


namespace app\my\traits;


trait MyStringHelper
{
    /**
     * 获取随机字符串
     *
     * @param int $length
     *
     * @return null|string
     */
    public static function getRandChar($length =32)
    {
        $str = NULL;
        $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        $max = strlen($strPol) - 1;

        for ($i = 0; $i < $length; $i ++) {
            $str .= $strPol[rand(0, $max)];
        }

        return $str;
    }


}